TableHeader = {}

function TableHeader:ctor()
    local label = Node.Label("编号"):wh(50, 30)
    label.labelSizeMode = LabelSizeMode.Custom
    label:addTo(self)
end

function TableHeader:setHeaders(headers)
    for i = 1, #headers do
        local header = headers[i]
        local label = Node.Label(header.name):wh(header.width or 100, 30)
        label.labelSizeMode = LabelSizeMode.Custom
        label:addTo(self)
    end
end

function Node.TableHeader(headers)
    local header = Node.Scale9("roundedBorderBox48")
    header.name = "TableHeader"
    header:addComponent(TableHeader)
    header:addComponent(Layout)
    header.layoutType = LayoutType.Horizontal
    header.leftPadding = 5
    header.rightPadding = 5
    header.layoutSizeMode = LayoutSizeMode.Stretch
    -- header.layoutSizeMode = LayoutSizeMode.StretchY
    -- header:addComponent(Stretch, {stretchType = StretchType.Horizontal})
    header:setHeaders(headers)
    return header
end